package com.lm.controller;

import com.aliyun.openservices.ons.api.Consumer;
import com.meirengu.controller.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("rocketmq")
public class RocketmqController extends BaseController {

    private static final Logger logger = LoggerFactory.getLogger(RocketmqController.class);

    @Autowired
    private Consumer consumer;

    @RequestMapping("/shutdown")
    @ResponseBody
    public void shutdown() {
        if (this.consumer != null) {
            this.consumer.shutdown();
            logger.info("Module:uc,Successfully close the redis");
        }
    }

    @ResponseBody
    @RequestMapping("/isStarted")
    public boolean isStarted() {
        return this.consumer.isStarted();
    }

    @ResponseBody
    @RequestMapping("/isClosed")
    public boolean isClosed() {
        return this.consumer.isClosed();
    }

}
